#define _CRT_SECURE_NO_WARNINGS
// https ://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&&tqId=11174&rp=1&ru=/activity/oj&qru=/ta/coding-interviews/question-ranking
class Solution {
public:
    bool IsPopOrder(vector<int> pushV, vector<int> popV) {
        stack<int> buffer;
        int popCpunt = 0;
        for (auto& e : pushV)
        {
            buffer.push(e);

            while (!buffer.empty() && buffer.top() == popV[popCpunt])
            {
                buffer.pop();
                ++popCpunt;
            }
        }
        return buffer.empty();
    }
};